#include "KPF_Task.h"

class KPF_TaskThread : public KPF_Thread
{
public:
	
	KPF_TaskThread( KPF_Task *pTask )
		: pm_KPFTask(pTask)
	{
		
	}
	
	virtual ~KPF_TaskThread( void )
	{
		
	}
	
	virtual void Run( void )
	{
		if ( pm_KPFTask )
		{
			pm_KPFTask->svr(  );
		}
	}
	
protected:
	KPF_TaskThread( void )
		: pm_KPFTask(NULL)
	{
		
	}
private:
	KPF_Task *pm_KPFTask;
};

KPF_Task::KPF_Task( void )
{
	memset( pm_ThreadArray, 0x00, sizeof(pm_ThreadArray) );
	
	pm_ThreadArray[0] = new KPF_TaskThread( this );
	
	if ( pm_ThreadArray[0] )
	{
		
	}
}

KPF_Task::KPF_Task( int count )
{
	memset( pm_ThreadArray, 0x00, sizeof(pm_ThreadArray) );
	
	if ( count < MAX_TASK_THREAD_SIZE )
	{
		int32_t i = 0;
	
		for ( i = 0; i < count; i++ )
		{
			pm_ThreadArray[i] = new KPF_TaskThread( this );
	
			if ( pm_ThreadArray[i] )
			{
		
			}	
		}
	}
}

int32_t KPF_Task::svr( void )
{
	int32_t iRetCode = -1;
	
	return iRetCode;
}

KPF_Task::~KPF_Task( void )
{
	int32_t i = 0;
	
	for ( i = 0; i < MAX_TASK_THREAD_SIZE; i++ )
	{
		if ( pm_ThreadArray[i] )
		{
			delete pm_ThreadArray[i];
			pm_ThreadArray[i] = NULL;
		}
	}
}
